<template>
  <div class="my-order">
    <div class="title">我的订单</div>
    <div class="list">
      <div class="item active" @click="itemClick(0)">
        <image class="icon" src="@/static/images/order/qbdd.png" />
        <div class="text">全部</div>
      </div>
      <div class="item active" @click="itemClick(1)">
        <image class="icon" src="@/static/images/order/dzf.png" />
        <div class="text">待支付</div>
      </div>
      <div class="item active" @click="itemClick(2)">
        <image class="icon" src="@/static/images/order/jxz.png" />
        <div class="text">进行中</div>
      </div>
      <div class="item active" @click="itemClick(3)">
        <image class="icon" src="@/static/images/order/ywc.png" />
        <div class="text">已完成</div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { switchTab } from '@/utils/page'
import { useUserStore } from '@/store/index'

defineOptions({ name: 'MyOrder' })

const userStore = useUserStore()

function itemClick(index) {
  if (userStore.isLogged) {
    uni.setStorageSync('orderStatusIndex', index)
    switchTab(`/pages/order/index`)
  } else {
    userStore.setShowModal(true)
  }
}
</script>
<style lang="scss" scoped>
.my-order {
  padding: 24rpx 30rpx 36rpx;
  margin: 40rpx 30rpx 0;
  background: #ffffff;
  border-radius: 30rpx;
  box-shadow: 0px 11rpx 19rpx 0 rgba(#000000, 0.05);

  .title {
    font-size: 30rpx;
    font-weight: 600;
    line-height: 36rpx;
    color: var(--color1);
  }
  .list {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30rpx;
    margin-top: 40rpx;
    .item {
      text-align: center;
      .icon {
        width: 57rpx;
        height: 57rpx;
      }
      .text {
        margin-top: 10rpx;
        font-size: 23rpx;
        color: var(--color2);
      }
    }
  }

  .tips {
    margin-top: 40rpx;
    font-size: 20rpx;
    color: var(--color4);
  }
}
</style>
